/**
 */
package generalbookings.impl;

import generalbookings.GeneralbookingsPackage;
import generalbookings.Option;
import generalbookings.Property;
import generalbookings.Resources;
import generalbookings.Service;
import generalbookings.ServiceTime;

import java.util.Collection;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.EObjectResolvingEList;
import org.eclipse.emf.ecore.util.InternalEList;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Service Time</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link generalbookings.impl.ServiceTimeImpl#getService <em>Service</em>}</li>
 *   <li>{@link generalbookings.impl.ServiceTimeImpl#getResources <em>Resources</em>}</li>
 *   <li>{@link generalbookings.impl.ServiceTimeImpl#getProperties <em>Properties</em>}</li>
 *   <li>{@link generalbookings.impl.ServiceTimeImpl#getServiceTimeOptions <em>Service Time Options</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class ServiceTimeImpl extends NamedElementImpl implements ServiceTime {
	/**
	 * The cached value of the '{@link #getService() <em>Service</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getService()
	 * @generated
	 * @ordered
	 */
	protected Service service;

	/**
	 * The cached value of the '{@link #getResources() <em>Resources</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getResources()
	 * @generated
	 * @ordered
	 */
	protected EList<Resources> resources;

	/**
	 * The cached value of the '{@link #getProperties() <em>Properties</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getProperties()
	 * @generated
	 * @ordered
	 */
	protected EList<Property> properties;

	/**
	 * The cached value of the '{@link #getServiceTimeOptions() <em>Service Time Options</em>}' reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getServiceTimeOptions()
	 * @generated
	 * @ordered
	 */
	protected EList<Option> serviceTimeOptions;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ServiceTimeImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return GeneralbookingsPackage.Literals.SERVICE_TIME;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Service getService() {
		if (service != null && service.eIsProxy()) {
			InternalEObject oldService = (InternalEObject)service;
			service = (Service)eResolveProxy(oldService);
			if (service != oldService) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, GeneralbookingsPackage.SERVICE_TIME__SERVICE, oldService, service));
			}
		}
		return service;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Service basicGetService() {
		return service;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setService(Service newService) {
		Service oldService = service;
		service = newService;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, GeneralbookingsPackage.SERVICE_TIME__SERVICE, oldService, service));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Resources> getResources() {
		if (resources == null) {
			resources = new EObjectContainmentEList<Resources>(Resources.class, this, GeneralbookingsPackage.SERVICE_TIME__RESOURCES);
		}
		return resources;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Property> getProperties() {
		if (properties == null) {
			properties = new EObjectContainmentEList<Property>(Property.class, this, GeneralbookingsPackage.SERVICE_TIME__PROPERTIES);
		}
		return properties;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Option> getServiceTimeOptions() {
		if (serviceTimeOptions == null) {
			serviceTimeOptions = new EObjectResolvingEList<Option>(Option.class, this, GeneralbookingsPackage.SERVICE_TIME__SERVICE_TIME_OPTIONS);
		}
		return serviceTimeOptions;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case GeneralbookingsPackage.SERVICE_TIME__RESOURCES:
				return ((InternalEList<?>)getResources()).basicRemove(otherEnd, msgs);
			case GeneralbookingsPackage.SERVICE_TIME__PROPERTIES:
				return ((InternalEList<?>)getProperties()).basicRemove(otherEnd, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case GeneralbookingsPackage.SERVICE_TIME__SERVICE:
				if (resolve) return getService();
				return basicGetService();
			case GeneralbookingsPackage.SERVICE_TIME__RESOURCES:
				return getResources();
			case GeneralbookingsPackage.SERVICE_TIME__PROPERTIES:
				return getProperties();
			case GeneralbookingsPackage.SERVICE_TIME__SERVICE_TIME_OPTIONS:
				return getServiceTimeOptions();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case GeneralbookingsPackage.SERVICE_TIME__SERVICE:
				setService((Service)newValue);
				return;
			case GeneralbookingsPackage.SERVICE_TIME__RESOURCES:
				getResources().clear();
				getResources().addAll((Collection<? extends Resources>)newValue);
				return;
			case GeneralbookingsPackage.SERVICE_TIME__PROPERTIES:
				getProperties().clear();
				getProperties().addAll((Collection<? extends Property>)newValue);
				return;
			case GeneralbookingsPackage.SERVICE_TIME__SERVICE_TIME_OPTIONS:
				getServiceTimeOptions().clear();
				getServiceTimeOptions().addAll((Collection<? extends Option>)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case GeneralbookingsPackage.SERVICE_TIME__SERVICE:
				setService((Service)null);
				return;
			case GeneralbookingsPackage.SERVICE_TIME__RESOURCES:
				getResources().clear();
				return;
			case GeneralbookingsPackage.SERVICE_TIME__PROPERTIES:
				getProperties().clear();
				return;
			case GeneralbookingsPackage.SERVICE_TIME__SERVICE_TIME_OPTIONS:
				getServiceTimeOptions().clear();
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case GeneralbookingsPackage.SERVICE_TIME__SERVICE:
				return service != null;
			case GeneralbookingsPackage.SERVICE_TIME__RESOURCES:
				return resources != null && !resources.isEmpty();
			case GeneralbookingsPackage.SERVICE_TIME__PROPERTIES:
				return properties != null && !properties.isEmpty();
			case GeneralbookingsPackage.SERVICE_TIME__SERVICE_TIME_OPTIONS:
				return serviceTimeOptions != null && !serviceTimeOptions.isEmpty();
		}
		return super.eIsSet(featureID);
	}

} //ServiceTimeImpl
